home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / ip / ka9q / aztecnos.arc / ECVEC.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-10-23  |  3.7 KB  |  202 lines

  1.     include lmacros.h
  2.  
  3. ; Conditional ES save/restore macros not in lmacros.h
  4. pushes    macro
  5.     ifdef LONGPTR
  6.     push    es
  7.     endif
  8.     endm
  9.  
  10. popes    macro
  11.     ifdef LONGPTR
  12.     pop    es
  13.     endif
  14.     endm
  15.  
  16.     ifdef    FARPROC
  17.     extrn    ecint_:far,doret:far
  18.     else
  19.     extrn    ecint_:near,doret:far
  20.     endif
  21.  
  22.     assume    ds:dataseg
  23.     extrn    _Dorg_:byte
  24.     extrn    Sssave:word,Spsave:word,Intstk_:byte
  25.     public    ec0vec_,ec1vec_,ec2vec_
  26.  
  27. dbase    dw    seg _Dorg_    ; save loc for ds (must be in code segment)
  28.  
  29. ; ec0vec - Ethernet interrupt handler
  30.  
  31. ec0vec_ proc    far
  32.     push    ds        ; save on user stack
  33.     mov    ds,cs:dbase    ; establish interrupt data segment
  34.  
  35.     mov    Sssave,ss    ; stash user stack context
  36.     mov    Spsave,sp
  37.  
  38.     mov    ss,cs:dbase
  39.     lea    sp,Intstk_+512
  40.  
  41.     push    ax        ; save user regs on interrupt stack
  42.     push    bx
  43.     push    cx
  44.     push    dx
  45.     push    bp
  46.     push    si
  47.     push    di
  48.     push    es
  49.     push    ds
  50.     pop    es
  51.  
  52.     mov    ax,0        ; arg for service routine
  53.     push    ax
  54.     call    ecint_
  55.     pop    ax
  56.     jmp    doret
  57. ec0vec_    endp
  58.  
  59. ; ec1vec - Ethernet interrupt handler
  60.  
  61. ec1vec_ proc    far
  62.     push    ds        ; save on user stack
  63.     mov    ds,cs:dbase    ; establish interrupt data segment
  64.  
  65.     mov    Sssave,ss    ; stash user stack context
  66.     mov    Spsave,sp
  67.  
  68.     mov    ss,cs:dbase
  69.     lea    sp,Intstk_+512
  70.  
  71.     push    ax        ; save user regs on interrupt stack
  72.     push    bx
  73.     push    cx
  74.     push    dx
  75.     push    bp
  76.     push    si
  77.     push    di
  78.     push    es
  79.     push    ds
  80.     pop    es
  81.  
  82.     mov    ax,1        ; arg for service routine
  83.     push    ax
  84.     call    ecint_
  85.     pop    ax
  86.     jmp    doret
  87. ec1vec_    endp
  88.  
  89. ; ec2vec - Ethernet interrupt handler
  90.  
  91. ec2vec_ proc    far
  92.     push    ds        ; save on user stack
  93.     mov    ds,cs:dbase    ; establish interrupt data segment
  94.  
  95.     mov    Sssave,ss    ; stash user stack context
  96.     mov    Spsave,sp
  97.  
  98.     mov    ss,cs:dbase
  99.     lea    sp,Intstk_+512
  100.  
  101.     push    ax        ; save user regs on interrupt stack
  102.     push    bx
  103.     push    cx
  104.     push    dx
  105.     push    bp
  106.     push    si
  107.     push    di
  108.     push    es
  109.     push    ds
  110.     pop    es
  111.  
  112.     mov    ax,2        ; arg for service routine
  113.     push    ax
  114.     call    ecint_
  115.     pop    ax
  116.     jmp    doret
  117. ec2vec_    endp
  118.  
  119. ; fast buffer I/O routines -- used by 3-COM Ethernet controller
  120.  
  121. ; outbuf - put a buffer to an output port
  122.     procdef outbuf,<<oport,word>,<obuf,ptr>,<ocnt,word>>
  123.     pushf
  124.     push    si
  125.     pushds
  126.     mov    dx,oport
  127.     mov    cx,ocnt
  128.     ldptr    si,obuf,ds    ; ds:si = obuf
  129.     cld
  130.  
  131. ; If buffer doesn't begin on a word boundary, send the first byte
  132.     test    si,1    ; (buf & 1) ?
  133.     jz    obufeven ; no
  134.     lodsb        ; al = *si++;
  135.     out    dx,al    ; out(dx,al);
  136.     dec    cx    ; cx--;
  137.     mov    ocnt,cx    ; save for later test
  138. obufeven:
  139.     shr    cx,1    ; cx = cnt >> 1; (convert to word count)
  140. ; Do the bulk of the buffer, a word at a time
  141.     jcxz    onobuf    ; if(cx != 0){
  142. xb:    lodsw        ; do { ax = *si++; (si is word pointer)
  143.     out    dx,al    ; out(dx,lowbyte(ax));
  144.     mov    al,ah
  145.     out    dx,al    ; out(dx,hibyte(ax));
  146.     loop    xb    ; } while(--cx != 0); }
  147. ; now check for odd trailing byte
  148. onobuf:    mov    cx,ocnt
  149.     test    cx,1
  150.     jz    ocnteven
  151.     lodsb        ; al = *si++;
  152.     out    dx,al
  153. ocnteven:
  154.     popds
  155.     pop    si
  156.     popf
  157.     pret
  158.     pend    outbuf
  159.  
  160. ; inbuf - get a buffer from an input port
  161.     procdef inbuf,<<iport,word>,<ibuf,ptr>,<icnt,word>>
  162.     pushf
  163.     push    di
  164.     pushes
  165.     mov    dx,iport
  166.     mov    cx,icnt
  167.     ldptr    di,ibuf,es    ; es:di = ibuf (es already set in small model)
  168.     cld
  169.  
  170. ; If buffer doesn't begin on a word boundary, get the first byte
  171.     test    di,1    ; if(buf & 1){
  172.     jz    ibufeven ;
  173.     in    al,dx    ; al = in(dx);
  174.     stosb        ; *di++ = al
  175.     dec    cx    ; cx--;
  176.     mov    icnt,cx    ; icnt = cx; } save for later test
  177. ibufeven:
  178.     shr    cx,1    ; cx = cnt >> 1; (convert to word count)
  179. ; Do the bulk of the buffer, a word at a time
  180.     jcxz    inobuf    ; if(cx != 0){
  181. rb:    in    al,dx    ; do { al = in(dx);
  182.     mov    ah,al
  183.     in    al,dx    ; ah = in(dx);
  184.     xchg    al,ah
  185.     stosw        ; *si++ = ax; (di is word pointer)
  186.     loop    rb    ; } while(--cx != 0);
  187. ; now check for odd trailing byte
  188. inobuf:    mov    cx,icnt
  189.     test    cx,1
  190.     jz    icnteven
  191.     in    al,dx
  192.     stosb        ; *di++ = al
  193. icnteven:
  194.     popes
  195.     pop    di
  196.     popf
  197.     pret
  198.     pend    inbuf
  199.  
  200.     finish
  201.     end
  202.